package com.example.demo.service.impl;

import com.example.demo.entity.Book;
import com.example.demo.mapper.BookMapper;
import com.example.demo.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;

    @Override
    public List<Book> selectBook(){
        List<Book> books=bookMapper.selectBook();
        System.out.println(books.size());
        return books;
    }

    @Override
    public List<Book> selectByName(String name) {
        List<Book> books=bookMapper.selectByName(name);
        System.out.println(books.size());
        return books;
    }

    @Override
    public List<Book> selectByType(int type) {
        List<Book> books=bookMapper.selectByType(type);
        System.out.println(books.size());
        return books;
    }

    @Override
    public void updateBNumber(int number, int id) {
        bookMapper.updateBNumber(number,id);
    }

    @Override
    public Book selectById(String id) {
        return bookMapper.selectById(id);
    }

    @Override
    public void updateBook(Book book) {
        bookMapper.updateBook(book);
    }

    @Override
    public void addBook(Book book) {
        bookMapper.addBook(book);
    }

    @Override
    public void delBook(String id) {
        bookMapper.delBook(id);
    }

    @Override
    public int selectBookNB(int bookId) {
        return bookMapper.selectBookNB(bookId);
    }
}
